#ifndef __MOTION_H
#define __MOTION_H

#include <SDL.h>
#include <stdio.h>
#include "main.h"
#include <SDL_image.h>
#include <SDL_ttf.h>
#include "init.h"
#include "texture.h"

typedef struct {
    int x, y;
    int r;
} Circle;

typedef struct {
    int posX;
    int posY;
    int speedX;
    int speedY;
} Motion;

typedef struct {
    Motion motion;
    SDL_Texture *texture;
    int w;
    int h;
    int dotSpeedRateX;
    int dotSpeedRateY;
    SDL_Rect colliders[9];
    int collidersNum;
    Circle circle;
} Dot;

typedef struct {
    int posX;
    int posY;
    Texture texture;
    int frame;
} Particles;

void initDot(Dot *dot, Texture *dotTexture);
void dotMove(Dot *dot, SDL_Rect *wallRect);
void dotHandle(Dot *dot, SDL_Event *e);
void freeDot(Dot *dot);
bool checkCollisionDot(Dot *dot, SDL_Rect *wallRect);
bool checkCollisionDotPerPixel(Dot *dotA, Dot *dotB);
void initDotWithPos(Dot *dot, Texture *dotTexture, int x, int y);
void dotMoveEx(Dot *dot, Dot *otherDot);
void updateColliderPos(Dot *dot);
void updateDotCirclePos(Dot *dot);
void dotMoveWithCircleAndRect(Dot *dot, Dot *otherDot, SDL_Rect *rect);
void dotMoveScroll(Dot *dot, SDL_Rect *edgeRect);
int random(int max);
void initParticals(Dot *dot, Particles p[], int pSize, Texture t[], int tSize);
void renderParticals(SDL_Renderer **render, Dot *dot, Particles p[], int pSize,  Texture t[], int tSize, Texture shimmer);


#endif
